#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

struct Student {
	string name;
	int score;
	Student() {}
	Student(string n, int s) : name(n), score(s) {}
};

bool cmp(Student s1, Student s2) {
	return s1.score > s2.score;
}

int main() {
	Student stu[3];
	for(int i = 0; i < 3; i++) {
		int s;
		string n;
		cin >> n >> s; 
		stu[i] = Student(n, s); 
	}
	for(int i = 0; i < 3; i++) {
		cout << stu[i].name << " " << stu[i].score << endl;
	}
	sort(stu, stu+3, cmp);
	for(int i = 0; i < 3; i++) {
		cout << stu[i].name << " " << stu[i].score << endl;
	}
	return 0;
} 
